+2004-01-16 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): New
+ get_volume_for_path() method.
+ (struct _GtkFileSystemIface): Finally removed the list_roots() and
+ get_root_info() methods, and the "roots-changed" signal.
+
+ * gtk/gtkfilesystem.c (gtk_file_system_get_volume_for_path): New
+ function.
+ (gtk_file_system_list_roots): Removed.
+ (gtk_file_system_get_root_info): Removed.
+
+ * gtk/gtkfilesystemunix.c
+ (gtk_file_system_unix_get_volume_for_path): Implement.
+ (get_root_volume): New helper function.
+ (gtk_file_system_unix_list_volumes): Use get_root_volume().
+ (gtk_file_system_unix_list_roots): Removed.
+ (gtk_file_system_unix_get_root_info): Removed.
+
+ * gtk/gtkfilesystemmodel.c (_gtk_file_system_model_new): Don't
+ accept a NULL root_path.
+ (struct _GtkFileSystemModel): Add a field to remember the
+ root_path.
+ (_gtk_file_system_model_new): Store the root_path in the model
+ structure.
+ (find_and_ref_path): Stop going up the hierarchy at the root_path
+ of the model. Also, don't return prematurely when walking up the
+ hierarchy.
+
+ * gtk/gtkfilechooserdefault.c (create_file_list): Sigh, restore
+ the rules_hint.
+ (struct _GtkFileChooserDefault): Added a current_volume_path field.
+ (set_tree_model): New function; create the folder tree model here.
+ (create_folder_tree): Don't create the model here.
+ (set_list_model): Set the show_hidden flag on the list model.
+
Fri Jan 16 00:04:43 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtknotebook.h:
+2004-01-16 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): New
+ get_volume_for_path() method.
+ (struct _GtkFileSystemIface): Finally removed the list_roots() and
+ get_root_info() methods, and the "roots-changed" signal.
+
+ * gtk/gtkfilesystem.c (gtk_file_system_get_volume_for_path): New
+ function.
+ (gtk_file_system_list_roots): Removed.
+ (gtk_file_system_get_root_info): Removed.
+
+ * gtk/gtkfilesystemunix.c
+ (gtk_file_system_unix_get_volume_for_path): Implement.
+ (get_root_volume): New helper function.
+ (gtk_file_system_unix_list_volumes): Use get_root_volume().
+ (gtk_file_system_unix_list_roots): Removed.
+ (gtk_file_system_unix_get_root_info): Removed.
+
+ * gtk/gtkfilesystemmodel.c (_gtk_file_system_model_new): Don't
+ accept a NULL root_path.
+ (struct _GtkFileSystemModel): Add a field to remember the
+ root_path.
+ (_gtk_file_system_model_new): Store the root_path in the model
+ structure.
+ (find_and_ref_path): Stop going up the hierarchy at the root_path
+ of the model. Also, don't return prematurely when walking up the
+ hierarchy.
+
+ * gtk/gtkfilechooserdefault.c (create_file_list): Sigh, restore
+ the rules_hint.
+ (struct _GtkFileChooserDefault): Added a current_volume_path field.
+ (set_tree_model): New function; create the folder tree model here.
+ (create_folder_tree): Don't create the model here.
+ (set_list_model): Set the show_hidden flag on the list model.
+
Fri Jan 16 00:04:43 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtknotebook.h:
+2004-01-16 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): New
+ get_volume_for_path() method.
+ (struct _GtkFileSystemIface): Finally removed the list_roots() and
+ get_root_info() methods, and the "roots-changed" signal.
+
+ * gtk/gtkfilesystem.c (gtk_file_system_get_volume_for_path): New
+ function.
+ (gtk_file_system_list_roots): Removed.
+ (gtk_file_system_get_root_info): Removed.
+
+ * gtk/gtkfilesystemunix.c
+ (gtk_file_system_unix_get_volume_for_path): Implement.
+ (get_root_volume): New helper function.
+ (gtk_file_system_unix_list_volumes): Use get_root_volume().
+ (gtk_file_system_unix_list_roots): Removed.
+ (gtk_file_system_unix_get_root_info): Removed.
+
+ * gtk/gtkfilesystemmodel.c (_gtk_file_system_model_new): Don't
+ accept a NULL root_path.
+ (struct _GtkFileSystemModel): Add a field to remember the
+ root_path.
+ (_gtk_file_system_model_new): Store the root_path in the model
+ structure.
+ (find_and_ref_path): Stop going up the hierarchy at the root_path
+ of the model. Also, don't return prematurely when walking up the
+ hierarchy.
+
+ * gtk/gtkfilechooserdefault.c (create_file_list): Sigh, restore
+ the rules_hint.
+ (struct _GtkFileChooserDefault): Added a current_volume_path field.
+ (set_tree_model): New function; create the folder tree model here.
+ (create_folder_tree): Don't create the model here.
+ (set_list_model): Set the show_hidden flag on the list model.
+
Fri Jan 16 00:04:43 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtknotebook.h:
+2004-01-16 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): New
+ get_volume_for_path() method.
+ (struct _GtkFileSystemIface): Finally removed the list_roots() and
+ get_root_info() methods, and the "roots-changed" signal.
+
+ * gtk/gtkfilesystem.c (gtk_file_system_get_volume_for_path): New
+ function.
+ (gtk_file_system_list_roots): Removed.
+ (gtk_file_system_get_root_info): Removed.
+
+ * gtk/gtkfilesystemunix.c
+ (gtk_file_system_unix_get_volume_for_path): Implement.
+ (get_root_volume): New helper function.
+ (gtk_file_system_unix_list_volumes): Use get_root_volume().
+ (gtk_file_system_unix_list_roots): Removed.
+ (gtk_file_system_unix_get_root_info): Removed.
+
+ * gtk/gtkfilesystemmodel.c (_gtk_file_system_model_new): Don't
+ accept a NULL root_path.
+ (struct _GtkFileSystemModel): Add a field to remember the
+ root_path.
+ (_gtk_file_system_model_new): Store the root_path in the model
+ structure.
+ (find_and_ref_path): Stop going up the hierarchy at the root_path
+ of the model. Also, don't return prematurely when walking up the
+ hierarchy.
+
+ * gtk/gtkfilechooserdefault.c (create_file_list): Sigh, restore
+ the rules_hint.
+ (struct _GtkFileChooserDefault): Added a current_volume_path field.
+ (set_tree_model): New function; create the folder tree model here.
+ (create_folder_tree): Don't create the model here.
+ (set_list_model): Set the show_hidden flag on the list model.
+
Fri Jan 16 00:04:43 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtknotebook.h:
+2004-01-16 Federico Mena Quintero <federico@ximian.com>
+
+ * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): New
+ get_volume_for_path() method.
+ (struct _GtkFileSystemIface): Finally removed the list_roots() and
+ get_root_info() methods, and the "roots-changed" signal.
+
+ * gtk/gtkfilesystem.c (gtk_file_system_get_volume_for_path): New
+ function.
+ (gtk_file_system_list_roots): Removed.
+ (gtk_file_system_get_root_info): Removed.
+
+ * gtk/gtkfilesystemunix.c
+ (gtk_file_system_unix_get_volume_for_path): Implement.
+ (get_root_volume): New helper function.
+ (gtk_file_system_unix_list_volumes): Use get_root_volume().
+ (gtk_file_system_unix_list_roots): Removed.
+ (gtk_file_system_unix_get_root_info): Removed.
+
+ * gtk/gtkfilesystemmodel.c (_gtk_file_system_model_new): Don't
+ accept a NULL root_path.
+ (struct _GtkFileSystemModel): Add a field to remember the
+ root_path.
+ (_gtk_file_system_model_new): Store the root_path in the model
+ structure.
+ (find_and_ref_path): Stop going up the hierarchy at the root_path
+ of the model. Also, don't return prematurely when walking up the
+ hierarchy.
+
+ * gtk/gtkfilechooserdefault.c (create_file_list): Sigh, restore
+ the rules_hint.
+ (struct _GtkFileChooserDefault): Added a current_volume_path field.
+ (set_tree_model): New function; create the folder tree model here.
+ (create_folder_tree): Don't create the model here.
+ (set_list_model): Set the show_hidden flag on the list model.
+
Fri Jan 16 00:04:43 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtknotebook.h:
guint bookmarks_changed_id;
+ GtkFilePath *current_volume_path;
GtkFilePath *current_folder;
GtkFilePath *preview_path;
shortcuts_append_bookmarks (GtkFileChooserDefault *impl)
{
GtkTreeIter iter;
- GSList *bookmarks;
gtk_tree_store_append (impl->shortcuts_model, &iter, NULL);
gtk_tree_store_set (impl->shortcuts_model, &iter,
gtk_container_add (GTK_CONTAINER (impl->tree_scrollwin), impl->tree);
gtk_widget_show (impl->tree);
- /* Model */
-
- impl->tree_model = _gtk_file_system_model_new (impl->file_system, NULL, -1,
- GTK_FILE_INFO_DISPLAY_NAME);
- _gtk_file_system_model_set_show_files (impl->tree_model, FALSE);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (impl->tree),
- GTK_TREE_MODEL (impl->tree_model));
-
/* Column */
gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (impl->tree), 0,
/* Tree/list view */
impl->list = gtk_tree_view_new ();
+ gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (impl->list), TRUE);
gtk_container_add (GTK_CONTAINER (impl->list_scrollwin), impl->list);
g_signal_connect (impl->list, "row_activated",
G_CALLBACK (list_row_activated), impl);
GTK_FILE_INFO_IS_FOLDER |
GTK_FILE_INFO_SIZE |
GTK_FILE_INFO_MODIFICATION_TIME);
+ _gtk_file_system_model_set_show_hidden (impl->list_model, impl->show_hidden);
install_list_model_filter (impl);
impl->sort_model = (GtkTreeModelSort *)gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (impl->list_model));
GTK_FILE_SYSTEM_MODEL_DISPLAY_NAME);
}
+/* Gets rid of the old folder tree model and creates a new one for the volume
+ * corresponding to the specified path.
+ */
+static void
+set_tree_model (GtkFileChooserDefault *impl, const GtkFilePath *path)
+{
+ GtkFileSystemVolume *volume;
+ GtkFilePath *volume_path;
+
+ volume = gtk_file_system_get_volume_for_path (impl->file_system, path);
+ volume_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
+
+ if (impl->current_volume_path && gtk_file_path_compare (volume_path, impl->current_volume_path) == 0)
+ goto out;
+
+ if (impl->tree_model)
+ g_object_unref (impl->tree_model);
+
+ impl->current_volume_path = gtk_file_path_copy (volume_path);
+
+ impl->tree_model = _gtk_file_system_model_new (impl->file_system, impl->current_volume_path, -1,
+ GTK_FILE_INFO_DISPLAY_NAME);
+ _gtk_file_system_model_set_show_files (impl->tree_model, FALSE);
+ _gtk_file_system_model_set_show_hidden (impl->tree_model, impl->show_hidden);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (impl->tree),
+ GTK_TREE_MODEL (impl->tree_model));
+
+ out:
+
+ gtk_file_path_free (volume_path);
+ gtk_file_system_volume_free (impl->file_system, volume);
+}
+
static void
update_chooser_entry (GtkFileChooserDefault *impl)
{
gtk_label_set_text (GTK_LABEL (impl->folder_label), str);
g_free (str);
- /* Notify the folder tree */
+ /* Update the folder tree */
if (!impl->changing_folder)
{
impl->changing_folder = TRUE;
+ set_tree_model (impl, impl->current_folder);
_gtk_file_system_model_path_do (impl->tree_model, path,
expand_and_select_func, impl);
impl->changing_folder = FALSE;
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- g_signal_new ("roots-changed",
- iface_type,
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GtkFileSystemIface, roots_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
g_signal_new ("bookmarks-changed",
iface_type,
G_SIGNAL_RUN_LAST,
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->list_volumes (file_system);
}
-GSList *
-gtk_file_system_list_roots (GtkFileSystem *file_system)
-{
- g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
-
- return GTK_FILE_SYSTEM_GET_IFACE (file_system)->list_roots (file_system);
-}
-
-GtkFileInfo *
-gtk_file_system_get_root_info (GtkFileSystem *file_system,
- const GtkFilePath *path,
- GtkFileInfoType types,
- GError **error)
-{
- g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
- g_return_val_if_fail (path != NULL, NULL);
- g_return_val_if_fail (error == NULL || *error == NULL, NULL);
-
- return GTK_FILE_SYSTEM_GET_IFACE (file_system)->get_root_info (file_system, path, types, error);
-}
-
GtkFileFolder *
gtk_file_system_get_folder (GtkFileSystem *file_system,
const GtkFilePath *path,
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->create_folder (file_system, path, error);
}
+/**
+ * gtk_file_system_get_volume_for_path:
+ * @file_system: a #GtkFileSystem
+ * @path: a #GtkFilePath
+ *
+ * Queries the file system volume that corresponds to a specific path.
+ *
+ * Return value: the #GtkFileSystemVolume that corresponds to the specified
+ * @path. You should free this value with gtk_file_system_volume_free().
+ **/
+GtkFileSystemVolume *
+gtk_file_system_get_volume_for_path (GtkFileSystem *file_system,
+ const GtkFilePath *path)
+{
+ g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+ g_return_val_if_fail (path != NULL, NULL);
+
+ return GTK_FILE_SYSTEM_GET_IFACE (file_system)->get_volume_for_path (file_system, path);
+}
+
/**
* gtk_file_system_volume_free:
* @file_system: a #GtkFileSystem
/**
* gtk_file_paths_copy:
- * @paths: A #GSList of 3GtkFilePath structures.
+ * @paths: A #GSList of #GtkFilePath structures.
*
* Copies a list of #GtkFilePath structures.
*
/* Methods
*/
- GSList * (*list_volumes) (GtkFileSystem *file_system);
- GSList * (*list_roots) (GtkFileSystem *file_system);
-
- GtkFileInfo * (*get_root_info) (GtkFileSystem *file_system,
- const GtkFilePath *path,
- GtkFileInfoType types,
- GError **error);
+ GSList * (*list_volumes) (GtkFileSystem *file_system);
+ GtkFileSystemVolume * (*get_volume_for_path) (GtkFileSystem *file_system,
+ const GtkFilePath *path);
GtkFileFolder * (*get_folder) (GtkFileSystem *file_system,
const GtkFilePath *path,
/* Signals
*/
void (*volumes_changed) (GtkFileSystem *file_system);
- void (*roots_changed) (GtkFileSystem *file_system);
void (*bookmarks_changed) (GtkFileSystem *file_system);
};
GType gtk_file_system_get_type (void);
GSList * gtk_file_system_list_volumes (GtkFileSystem *file_system);
-GSList * gtk_file_system_list_roots (GtkFileSystem *file_system);
-GtkFileInfo * gtk_file_system_get_root_info (GtkFileSystem *file_system,
- const GtkFilePath *path,
- GtkFileInfoType types,
- GError **error);
+
+GtkFileSystemVolume *gtk_file_system_get_volume_for_path (GtkFileSystem *file_system,
+ const GtkFilePath *path);
void gtk_file_system_volume_free (GtkFileSystem *file_system,
GtkFileSystemVolume *volume);
GtkFileInfoType types;
FileModelNode *roots;
GtkFileFolder *root_folder;
+ GtkFilePath *root_path;
GtkFileSystemModelFilter filter_func;
gpointer filter_data;
static FileModelNode * file_model_node_get_children (GtkFileSystemModel *model,
FileModelNode *node);
+#if 0
static void roots_changed_callback (GtkFileSystem *file_system,
GtkFileSystemModel *model);
+#endif
static void deleted_callback (GtkFileFolder *folder,
FileModelNode *node);
/**
* _gtk_file_system_model_new:
* @file_system: an object implementing #GtkFileSystem
- * @root_path: the path of root of the file system to display,
- * or %NULL to display starting from the
- * root or roots of the fielsystem.
+ * @root_path: the path of root of the file system to display
* @max_depth: the maximum depth from the children of @root_path
* or the roots of the file system to display in
* the file selector). A depth of 0 displays
GSList *tmp_list;
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+ g_return_val_if_fail (root_path != NULL, NULL);
model = g_object_new (GTK_TYPE_FILE_SYSTEM_MODEL, NULL);
model->file_system = g_object_ref (file_system);
if (root_path)
{
GSList *child_paths;
-
+
+ model->root_path = gtk_file_path_copy (root_path);
model->root_folder = gtk_file_system_get_folder (file_system, root_path,
model->types,
NULL); /* NULL-GError */
G_CALLBACK (root_files_removed_callback), model, 0);
}
}
+#if 0
else
{
roots = gtk_file_system_list_roots (file_system);
g_signal_connect_object (file_system, "roots-changed",
G_CALLBACK (roots_changed_callback), model, 0);
}
+#endif
roots = gtk_file_paths_sort (roots);
FileModelNode *child_node;
GtkFileFolder *folder;
- if (!gtk_file_system_get_parent (model->file_system, path, &parent_path, NULL))
+ if (gtk_file_path_compare (path, model->root_path) == 0
+ || !gtk_file_system_get_parent (model->file_system, path, &parent_path, NULL))
return NULL;
if (parent_path)
{
parent_node = find_and_ref_path (model, parent_path, cleanups);
gtk_file_path_free (parent_path);
-
- if (!parent_node)
- return NULL;
}
else
parent_node = NULL;
node->path,
NULL); /* NULL-GError */
}
+#if 0
else
{
node->info = gtk_file_system_get_root_info (model->file_system,
model->types,
NULL); /* NULL-GError */
}
+#endif
}
return node->info;
g_slist_free (sorted_paths);
}
+#if 0
static void
roots_changed_callback (GtkFileSystem *file_system,
GtkFileSystemModel *model)
g_slist_free (new_roots);
gtk_tree_path_free (path);
}
+#endif
static void
deleted_callback (GtkFileFolder *folder,
static void gtk_file_system_unix_init (GtkFileSystemUnix *impl);
static void gtk_file_system_unix_finalize (GObject *object);
-static GSList * gtk_file_system_unix_list_volumes (GtkFileSystem *file_system);
-static GSList * gtk_file_system_unix_list_roots (GtkFileSystem *file_system);
-static GtkFileInfo * gtk_file_system_unix_get_root_info (GtkFileSystem *file_system,
- const GtkFilePath *path,
- GtkFileInfoType types,
- GError **error);
+static GSList * gtk_file_system_unix_list_volumes (GtkFileSystem *file_system);
+static GtkFileSystemVolume *gtk_file_system_unix_get_volume_for_path (GtkFileSystem *file_system,
+ const GtkFilePath *path);
+
static GtkFileFolder *gtk_file_system_unix_get_folder (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFileInfoType types,
gtk_file_system_unix_iface_init (GtkFileSystemIface *iface)
{
iface->list_volumes = gtk_file_system_unix_list_volumes;
- iface->list_roots = gtk_file_system_unix_list_roots;
+ iface->get_volume_for_path = gtk_file_system_unix_get_volume_for_path;
iface->get_folder = gtk_file_system_unix_get_folder;
- iface->get_root_info = gtk_file_system_unix_get_root_info;
iface->create_folder = gtk_file_system_unix_create_folder;
iface->volume_free = gtk_file_system_unix_volume_free;
iface->volume_get_base_path = gtk_file_system_unix_volume_get_base_path;
system_parent_class->finalize (object);
}
-static GSList *
-gtk_file_system_unix_list_volumes (GtkFileSystem *file_system)
+/* Returns our single root volume */
+static GtkFileSystemVolume *
+get_root_volume (void)
{
- return g_slist_append (NULL, gtk_file_path_new_dup ("/"));
+ return (GtkFileSystemVolume *) gtk_file_path_new_dup ("/");
}
static GSList *
-gtk_file_system_unix_list_roots (GtkFileSystem *file_system)
+gtk_file_system_unix_list_volumes (GtkFileSystem *file_system)
{
- return g_slist_append (NULL, gtk_file_path_new_dup ("/"));
+ return g_slist_append (NULL, get_root_volume ());
}
-static GtkFileInfo *
-gtk_file_system_unix_get_root_info (GtkFileSystem *file_system,
- const GtkFilePath *path,
- GtkFileInfoType types,
- GError **error)
+static GtkFileSystemVolume *
+gtk_file_system_unix_get_volume_for_path (GtkFileSystem *file_system,
+ const GtkFilePath *path)
{
- const gchar *filename = gtk_file_path_get_string (path);
-
- g_return_val_if_fail (strcmp (filename, "/") == 0, NULL);
-
- return filename_get_info ("/", types, error);
+ return get_root_volume ();
}
static GtkFileFolder *